<?php
$con = mysql_connect("localhost","root","root");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

mysql_select_db("comds", $con);
$dateTime = date("Y-m-d",strtotime("-1 day"));
#$dateTime = '2012-04-14';

mysql_query("INSERT INTO blacklist
SELECT max( id ) , TotalExp, FirstLoginTime, FirstLogin, TotalDollorGet, TodayGameTime, TodayTCrystalLose, Crystal, TodayGoldGet, TodayGoldLose, Cracked, WeaponList, TodayExp, 
TodayIapInfo, 099cents1, 099cents2, new499cents1, new499cents2, new999cents1, new999cents2, new1999cents1, new1999cents2, new4999cents1, new4999cents2, ChoosePointsUI, 
ShopUI_Weapon, ShopUI_Avatar, ShopUI_PowerUPS, ShopUI_Bank, BoostUI_Skill, TeamUI_Friend, TeamUI_MERC, MERC_UI, OptionUI, BattleUI_Pause, BattleUI_Item, BattleUI_Dead, ExchangeUI, Gold,
LEVEL , GameActiveTime, TotalGoldGet, UILastId, HireoutSelfTimes, TotalGameTime, TodayTCrystalGet, deviceid, gamename, createdate, date
FROM  comds_query where
(
099cents1 *99 + new499cents1 *499 + new999cents1 *999 + new1999cents1 *1999 + new4999cents1 *4999 + 099cents2 *99 + new499cents2 *499 + new999cents2 *999 + new1999cents2 *1999 + new4999cents2 *4999
) >20000
AND Cracked =0
GROUP BY deviceid");
mysql_query("delete from comds_query where (099cents1 *99 + new499cents1 *499 + new999cents1 *999 + new1999cents1 *1999 + new4999cents1 *4999 + 099cents2 *99 + new499cents2 *499 + new999cents2 *999 + new1999cents2 *1999 + new4999cents2 *4999) >20000 AND Cracked =0");

mysql_close($con);
?>